
<?php
$posttitle = "";
$postdesc = "";
$postcontent = "";
$access ="";
$metakey = "";
$metadesc = "";
$publishup = "";
$publishdown ="";
$tagline ="";
$seotitle ="";
$cat_id ="";
$feauter = 0;
if(!empty($posts)){
    $posttitles = $this->_global->_unserialize($posts->post_title);
    if(!empty($posttitles[$this->session->userdata('lan')]))
    $posttitle = $posttitles[$this->session->userdata('lan')]['post_title'];
    else
    $posttitle = "Không tồn tại tiêu đề bài viết với ngôn ngữ hiện tại";
    if(!empty($posts->post_desc)){
        $postdescs = $this->_global->_unserialize($posts->post_desc);
        $postdesc = isset($postdescs[$this->session->userdata('lan')]['post_desc'])?$postdescs[$this->session->userdata('lan')]['post_desc']:"";   
    }    
    if(!empty($posts->post_content)){
        $postcontents = $this->_global->_unserialize($posts->post_content);
        $postcontent = isset($postcontents[$this->session->userdata('lan')]['post_content'])?$postcontents[$this->session->userdata('lan')]['post_content']:"";   
    }
    if(!empty($posts->seo_title)){
        $seotitles = $this->_global->_unserialize($posts->seo_title);
        $seotitle = isset($seotitles[$this->session->userdata('lan')]['seo_title'])?$seotitles[$this->session->userdata('lan')]['seo_title']:"";
    }
    
    
    $access = $posts->access;
    $metakey = $posts->metakey;
    $metadesc = $posts->metadesc;
    $publishup = date('d/m/Y',$posts->publish_up);
    $publishdown = date('d/m/Y',$posts->publish_down);
    $tagline = $posts->tagline;
    $cat_id = $posts->cat_id;
    $feauter = $posts->feature  ;
    
}
?>

<div class="" id="myModal" >
  <div class="modal-header">
    <h3 style="text-transform: capitalize;"><?php echo $action ?> Post</h3>
  </div>
<?php echo form_open('administrator/article/posts/save') ?>

    <label for="post_title">Title:</label><input type="text" value="<?php echo $posttitle; ?>" name="title" id="title" />
     <label for="seo_title">Seo title:</label>
     <input type="text" value="<?php echo $seotitle ?>" name="seo_title" id="seo_title" value="<?php echo $seotitle?>" />
    <label for="post_desc">Description</label><textarea  name="post_desc" id="post_desc" class="large"><?php echo $postdesc ?></textarea>
    <label for="post_content">Content</label><textarea name="content" id="content" class="large"><?php echo $postcontent?></textarea>
    <label for="parent">Category:</label>
            <select name="cat_id">
                <?php 
                if(count($categories)>0):?>
                    <?php foreach($categories as $cat):
                        $cat_name = $this->_global->_unserialize($cat->cat_name)
                    ?>
                        <option  <?php echo $cat->cat_id==$cat_id?"selected='selected'":"" ?> value="<?php echo $cat->cat_id;?>">
                        <?php echo isset($cat_name[$this->session->userdata('lan')]['title'])?$cat_name[$this->session->userdata('lan')]['title']:"Không tồn tại tiêu đề danh mục với ngôn ngữ hiện tại";?></option>
                    <?php endforeach?>
                <?php endif?>
            </select>
     <label for="access">Access:</label>
            <select name="access">
                <option value="0">All</option>
                <?php if(count($roles)>0):?>
                    <?php foreach($roles as $rol):?>
                        <option <?php echo $rol->rolesID==$access?"selected='selected'":"" ?> value="<?php echo $rol->rolesID;?>"><?php echo $rol->name;?></option>
                    <?php endforeach?>
                <?php endif?>
            </select>
            <label class="radio">
                <input type="radio" name="feauter" value="0" <?php echo $feauter==0?"checked='checked'":"" ?>/> None
            </label>
            <label class="radio">
                <input type="radio" name="feauter" value="1" <?php echo $feauter==1?"checked='checked'":"" ?>/> Hiện ngoài trang chủ và trang danh mục
            </label>
            <label class="radio">
                <input type="radio" name="feauter" value="2" <?php echo $feauter==2?"checked='checked'":"" ?>/> Chỉ hiện ở trang danh mục
            </label>
     <label for="tagline">Date Up:</label>
        <input type="text" name="publish_up" id="startdate" value="<?php echo $publishup?>"/>
        <label for="tagline">Date Down:</label>
        <input type="text" name="publish_down" id="enddate" value="<?php echo $publishdown?>"/>
     <label for="tagline">Tag:</label>
        <input type="text" name="tagline" id="tagline" value="<?php echo $tagline?>" />
        <label for="metakey">Metakey:</label>
        <input type="text" name="metakey" id="metakey" value="<?php echo $metakey?>" />
        <label for="metadesc">Metadesc:</label>
        <textarea name="metadesc" id="metadesc" class="large" ><?php echo $metadesc?></textarea>
    
        <div class="modal-footer">
    <input type="submit" class="btn btn-primary"  value="Save"/>
    <a href="<?php echo base_url().'/administrator/article/posts/'?>" class="btn">Cancel</a>
    <input type="hidden" name="action"  value="<?php echo $action ?>" id="action" />
    <input type="hidden" name="post_id"  value="<?php echo $post_id?>" id="post_id" />
  </div> 
</form></div>